package cn.houserent.dao;

import cn.houserent.entity.House;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import java.util.List;

public class HouseDaoImpl extends HibernateDaoSupport implements HouseDao {

    @Override
    public House getHouseById(int houseId) {
        return this.getHibernateTemplate().get(House.class,houseId);
    }

    @Override
    public List<House> getHouseByTitle(String title) {
        if (null==title || "".equals(title)){
            //查询全部
            return this.getHibernateTemplate().find("from House");
        }else {
            String hql ="from House where title like ? ";
            title = "%".concat(title).concat("%");
            return this.getHibernateTemplate().find(hql,title);
        }

    }
}
